<?php
// 初始化一个 cURL 对象
if(!function_exists('curl_init')) {
	exit('no curl');
}

$curl = curl_init();

// 设置你需要抓取的URL
curl_setopt($curl, CURLOPT_URL, 'http://localhost/phpinfo.php');
//curl_setopt($curl, CURLOPT_URL, 'http://127.0.0.1');
//curl_setopt($curl, CURLOPT_URL, 'http://www.baidu.com');

// 设置header
// TRUE to include the header in the output.
curl_setopt($curl, CURLOPT_HEADER, TRUE);

// 设置cURL 参数，要求结果保存到字符串中还是输出到屏幕上。
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
//curl_setopt($curl, CURLOPT_TIMEOUT, 5);
//curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, TRUE);
//curl_setopt($curl, CURLOPT_PROXY, '87.254.212.121:8080');
//url_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:password'); //如果要密码的话，加上这个  

// 运行cURL，请求网页
$data = curl_exec($curl);
if($data === FALSE) {
	exit('cUrl error: '.curl_error($curl));
}

$info = curl_getinfo($curl);

// 关闭URL请求
curl_close($curl);

// 显示获得的数据
ob_start();
var_dump($data);
$ret = ob_get_clean();
ob_end_clean();
echo '<pre>'.$ret.'</pre>';